package com.jdone.compus.service;

import com.jdone.compus.enums.ConsumptionStatus;
import com.jdone.compus.model.StudentOrder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;

public interface StudentOrderService {
    //保存订单
    StudentOrder save(StudentOrder order);

    //修改订单支付状态
    StudentOrder updateOrderStatusByOrderNumber(String orderNumber);

    // 创建订单
    StudentOrder createOrder(StudentOrder order);

    // 根据订单ID获取订单
    Optional<StudentOrder> getOrderById(Long id);

    // 根据业务订单号获取订单
    Optional<StudentOrder> getOrderByBusinessOrderNo(String businessOrderNo);

    // 根据学生ID获取所有订单
    Iterable<StudentOrder> getOrdersByStudentId(String studentId);

    // 根据订单ID更新订单状态
    StudentOrder updateOrderStatus(Long id, ConsumptionStatus status);

    // 删除订单
    void deleteOrder(Long id);

    // 更新订单信息
    StudentOrder updateOrder(Long id, StudentOrder order);

    Page<StudentOrder> findOrdersByCreateTime(LocalDateTime startDate, LocalDateTime endDate, ConsumptionStatus consumptionStatus, String businessOrderNo, Pageable pageable);

    Page<StudentOrder> getOrdersByStudentIdAndDateRange(String studentId, LocalDate startDate, LocalDate endDate, Pageable pageable);

    Map<String, Object> getOrderStats(LocalDateTime startDateTime, LocalDateTime endDateTime);

    ByteArrayInputStream exportAllOrdersToExcel() throws IOException;
}

